
    (function () {
        let qr = getUrlParams(location.href)
        console.log(qr.productid);
        $.ajax({ url: `http://chst.vip:1234/api/getdiscountproduct?productid=${qr.productid}` })
            .then(res => {
                let newData = [...res.result]
                console.log(newData);
                let page = ''
                let html = ''
                newData.forEach(item => {
                    page += `
                <div class="title">
                    <h4>${item.productName}</h4>
                </div>
                <div class="other">
                    <span class="mall fl">${item.productFrom} | ${item.productTime}</span>
                    <i>${item.productTips}</i>
                    <div>${item.productPrice}</div>
                </div>
                <div class="container">
                    <div class="info2">
                        ${item.productInfo}
                    </div>
                    <p>
                        ${item.productImg}
                    </p>
                </div>
                `
                    html += `
                ${item.productComment}
                `
                })
                $('.infoR').html(page)
                $('.comment').html(html)
            })
    })()




    var ul = document.querySelector('.marskSm .info');
    var lis = document.querySelectorAll('.marskSm li');
    ul.style.width = lis.length * lis[0].offsetWidth + 'px';
    
    console.log(ul);
    console.log(lis);
    var index = 0;
    var flag = true;
    $('.arrRight').click(function(num){
        if(flag){
            flag = false
            index++
            if(index<=lis.length-1){
                ul.style.transform = 'translateX(' + -index * lis[0].offsetWidth + 'px' + ')';
                ul.style.transition = '.5s ease-in-out'
            }else{
                index = lis.length-1;
                    alert('已经是最后一页啦');
                    flag = true;
            }
        }
        ul.addEventListener('webkitTransitionEnd', function () {
            flag = true;
    })
})
$('.arrLeft').click(function(num){
    if(flag){
        index--;
        flag = false;
        if(index>=0){
            ul.style.transform = 'translateX(' + -index * lis[0].offsetWidth + 'px' + ')';
            ul.style.transition = '.5s ease-in-out'
        }else{
            index = 0;
            alert('已经是第一页啦');
            // return;
            flag = true;
        }
    }
    ul.addEventListener('webkitTransitionEnd', function () {
        // flag = true;
    }) 
})
  //每一个单个点击事件
  $('#product .info').find('li').click(function () {
    $('.carousel').css({'transform': 'translateY(0px)', 'transition': '.7s ease-in-out'});
    ul.style.transition = 'none';
    index = $(this).data('index');
    ul.style.transform = 'translateX(' + -index * lis[0].offsetWidth + 'px' + ')';
});
 //关闭点击事件
 $('.marskSm').find('i').click(function () {
    $('.carousel').css('transform', 'translateY(-1000px)');
})